//
//  SecondViewController.m
//  手机通讯录
//
//  Created by Roach on 16/6/17.
//  Copyright © 2016年 lanou. All rights reserved.

#import "SecondViewController.h"

#import "ViewController.h"

@interface SecondViewController ()<UITextFieldDelegate>
@property (nonatomic, retain) NSArray *labelArray;
@property (nonatomic, retain) NSArray *textArray;
@property (nonatomic, retain) UITextField *nameTextField;
@property (nonatomic, retain) UITextField *numberTextField;
@property (nonatomic, retain) UITextField *QQTextField;
@property (nonatomic, retain) NSString *image;
@property (nonatomic, retain) UIButton *button;

@end

@implementation SecondViewController

- (void)dealloc {
    [_QQTextField release];
    [_numberTextField release];
    [_image release];
    [_button release];
    [_labelArray release];
    [_nameTextField release];
    [_textArray release];
    [super dealloc];
    
}

- (void)viewDidLoad {
    
    [self config];
    
    [self creatView];
    
    
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)config {
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"name";
    
    // 右边按钮
    UIBarButtonItem *itemOfRight = [[UIBarButtonItem alloc]initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction:)];
    
    self.navigationItem.rightBarButtonItems = @[itemOfRight];
    [itemOfRight release];
    
}


- (void)creatView {
    // 姓名
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 380, 50, 30)];
    nameLabel.text = @"姓名";
    nameLabel.backgroundColor = [UIColor greenColor];
    [self.view addSubview:nameLabel];
    [nameLabel release];
    nameLabel.font = [UIFont systemFontOfSize:24];
    self.nameTextField = [[UITextField alloc]initWithFrame:CGRectMake(100, 380, 270, 30)];
    
    _nameTextField.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:_nameTextField];
    [_nameTextField release];
    _nameTextField.font = [UIFont systemFontOfSize:24];
    _nameTextField.textAlignment = NSTextAlignmentCenter;
    // 电话
    UILabel *numberLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 430, 50, 30)];
    numberLabel.text = @"电话";
    numberLabel.backgroundColor = [UIColor greenColor];
    [self.view addSubview:numberLabel];
    numberLabel.font = [UIFont systemFontOfSize:24];
    [numberLabel release];
    
    self.numberTextField = [[UITextField alloc]initWithFrame:CGRectMake(100, 430, 270, 30)];
    _numberTextField.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:_numberTextField];
    [_numberTextField release];
    _numberTextField.font = [UIFont systemFontOfSize:24];
    _numberTextField.textAlignment = NSTextAlignmentCenter;
    
    // QQ
    UILabel *QQLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 480, 50, 30)];
    QQLabel.text = @"QQ";
    QQLabel.backgroundColor = [UIColor greenColor];
    [self.view addSubview:QQLabel];
    [QQLabel release];
    QQLabel.font = [UIFont systemFontOfSize:24];
    
    self.QQTextField = [[UITextField alloc]initWithFrame:CGRectMake(100, 480, 270, 30)];
    _QQTextField.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:_QQTextField];
    [_QQTextField release];
    _QQTextField.font  = [UIFont systemFontOfSize:24];
    _QQTextField.textAlignment = NSTextAlignmentCenter;
    
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.button setImage:[UIImage imageNamed:self.headerImage] forState:UIControlStateNormal];
    self.button.frame = CGRectMake(150, 150, 100, 100);
    self.button.layer.cornerRadius = 50;
    self.button.layer.masksToBounds = YES;
    
    [self.view addSubview:self.button];
    
    
    self.nameTextField.text = self.nametextField;
    self.numberTextField.text = self.numbertextField;
    self.QQTextField.text = self.QQtextField;
    
}


// 右边按钮
- (void)rightAction:(UIBarButtonItem *)right {
    
    [self.delegate sendText:self.nameTextField.text];
    
    NSLog(@"%@", self.nameTextField.text);
    
    [self.navigationController popViewControllerAnimated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
